package ApacheCommons.lang;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.list.LazyList;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 如果获取的下标不存在则会自动生成对应的长度并且设置默认值，其间的数据全部会设置为null 则会返回默认值
 * @author zhoujie
 * @date 2020-07-31
 */
@Slf4j
public class LazyListTest {
    @Test
    public void test01(){
        List lazyList = LazyList.decorate(new ArrayList(), () -> "sky");
        lazyList.add("data");
        log.info(Objects.toString(lazyList.get(100)));
        log.info("list size [{}]",lazyList.size());
        log.info("list  [{}]",Objects.toString(lazyList));
    }
}
